
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>creoleparser.dialects &amp;mdash; creoleparser v0.7.3 documentation</title>
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
          URL_ROOT:    '../',
          VERSION:     '0.7.3',
          COLLAPSE_MODINDEX: false,
          FILE_SUFFIX: '.html'
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="top" title="creoleparser v0.7.3 documentation" href="../index.html" />
    <link rel="up" title="Generated API documentation" href="../modules.html" />
    <link rel="next" title="creoleparser.core" href="core.html" />
    <link rel="prev" title="Generated API documentation" href="../modules.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             accesskey="">modules</a> |</li>
        <li class="right" >
          <a href="core.html" title="creoleparser.core"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="../modules.html" title="Generated API documentation"
             accesskey="P">previous</a> |</li>
        <li><a href="../contents.html">creoleparser v0.7.3 documentation</a> &raquo;</li>
          <li><a href="../modules.html" accesskey="U">Generated API documentation</a> &raquo;</li> 
      </ul>
    </div>  
    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-creoleparser.dialects">
<span id="creoleparser-dialects"></span><h1><a class="reference internal" href="#module-creoleparser.dialects" title="creoleparser.dialects"><tt class="xref py py-mod docutils literal"><span class="pre">creoleparser.dialects</span></tt></a><a class="headerlink" href="#module-creoleparser.dialects" title="Permalink to this headline">¶</a></h1>
<dl class="function">
<dt id="creoleparser.dialects.create_dialect">
<tt class="descclassname">creoleparser.dialects.</tt><tt class="descname">create_dialect</tt><big>(</big><em>dialect_base</em>, <em>**kw_args</em><big>)</big><a class="headerlink" href="#creoleparser.dialects.create_dialect" title="Permalink to this definition">¶</a></dt>
<dd><p>Factory function for dialect objects (for parameter defaults,
see <a class="reference internal" href="#creoleparser.dialects.creole10_base" title="creoleparser.dialects.creole10_base"><tt class="xref py py-func docutils literal"><span class="pre">creole10_base()</span></tt></a> and/or
<a class="reference internal" href="#creoleparser.dialects.creole11_base" title="creoleparser.dialects.creole11_base"><tt class="xref py py-func docutils literal"><span class="pre">creole11_base()</span></tt></a>)</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><dl class="first last docutils">
<dt>add_heading_ids</dt>
<dd><p class="first last">If <cite>True</cite>, user friendly, lowercase, unique, id attributes will be
automatically added to headings. To prevent clashes with other page
ids, all will be prefixed with a &#8221;!&#8221;. This prefix may be changed by
passing a string rather than a boolean. <em>``environ`` needs to be a
dicionary-like object for this to function</em>
(see <a class="reference internal" href="core.html#creoleparser.core.Parser.parse" title="creoleparser.core.Parser.parse"><tt class="xref py py-meth docutils literal"><span class="pre">creoleparser.core.Parser.parse()</span></tt></a>) and a key named <cite>ids</cite>
will be added.</p>
</dd>
<dt>argument_parser</dt>
<dd><p class="first last">Parser used for automatic parsing of macro arg strings. Must take a
single string argument and return a two-tuple with the first element
a list (for positional arguments) and the second a dictionary (for
keyword arguments). A default is supplied. Individual macros may
override this parser by providing their own as a function attribute
named <cite>arg_parser</cite>.</p>
</dd>
<dt>blog_style_endings</dt>
<dd><p class="first last">If <cite>True</cite>, each newline character in a paragraph will be converted to
a &lt;br /&gt;. Note that the escaping mechanism (tilde) does not work
for newlines.</p>
</dd>
<dt>bodied_macros</dt>
<dd><p class="first">Dictionary of macros (functions). If a bodied macro is found that is not
in this dictionary, <tt class="docutils literal"><span class="pre">macro_func</span></tt> (below) will be called instead. Each
function must accept the following positional arguments:</p>
<ol class="arabic simple">
<li>macro object. This dictionary-like object has attributes
<tt class="docutils literal"><span class="pre">macro_name</span></tt>, <tt class="docutils literal"><span class="pre">body</span></tt>,
<tt class="docutils literal"><span class="pre">isblock</span></tt>, and <tt class="docutils literal"><span class="pre">arg_string</span></tt> (see <tt class="docutils literal"><span class="pre">macro_func</span></tt> (below) for more
information). Additionally, the macro object has a <tt class="docutils literal"><span class="pre">parsed_body()</span></tt>
method, that will return the parsed <tt class="docutils literal"><span class="pre">macro.body</span></tt> as a
genshi.Fragment. <tt class="docutils literal"><span class="pre">parsed_body()</span></tt> takes an optional <tt class="docutils literal"><span class="pre">context</span></tt>
argument, that defaults to <cite>auto</cite>, see <a class="reference internal" href="core.html#creoleparser.core.Parser.parse" title="creoleparser.core.Parser.parse"><tt class="xref py py-meth docutils literal"><span class="pre">creoleparser.core.Parser.parse()</span></tt></a>
for other possible values.</li>
<li>the <cite>environ</cite> object (see <a class="reference internal" href="core.html#creoleparser.core.Parser.parse" title="creoleparser.core.Parser.parse"><tt class="xref py py-meth docutils literal"><span class="pre">creoleparser.core.Parser.parse()</span></tt></a>)</li>
</ol>
<p>If the found macro includes arguments, they will be included in
the function call. Creoleparser will handle exceptions by returning an
error message in place of the macro (possibly including a traceback).
Python&#8217;s syntax for accepting arbitrary arguments is often used for
macros (e.g.,def mymacro(macro, env, *pos, **kw)).</p>
<p class="last">For information on return values, see macro_func (below).</p>
</dd>
<dt>non_bodied_macros</dt>
<dd><p class="first last">Same as <tt class="docutils literal"><span class="pre">bodied_macros</span></tt> but used for non-bodied macros.</p>
</dd>
<dt>custom_markup</dt>
<dd><p class="first">List of tuples that can each define arbitrary custom wiki markup such
as WikiWords and emoticons. Each tuple must have two elements,
as follows:</p>
<ol class="arabic">
<li><p class="first">Compiled regular expression or string (<em>not</em> an re pattern) to match.</p>
</li>
<li><p class="first">Function that takes two postional arguments, as follows:</p>
<ol class="arabic simple">
<li>the match object</li>
<li>the <cite>environ</cite> object (see <a class="reference internal" href="core.html#creoleparser.core.Parser.parse" title="creoleparser.core.Parser.parse"><tt class="xref py py-meth docutils literal"><span class="pre">creoleparser.core.Parser.parse()</span></tt></a>)</li>
</ol>
<p>The function must return a Genshi object (Stream, Markup,
builder.Fragment, or builder.Element). Returning a string will
raise an error.</p>
</li>
</ol>
<p class="last">As a shortcut for simple cases, the second tuple element may be
a string rather than a function. The string will be wrapped in a Markup
object (to allow pass-through of HTML) and a Fragment object (to prevent
Creoleparser from creating a new paragraph).</p>
</dd>
<dt>dialect_base</dt>
<dd><p class="first last">The class factory to use for creating the dialect object.
<tt class="docutils literal"><span class="pre">creoleparser.dialects.creole10_base</span></tt> and  
<tt class="docutils literal"><span class="pre">creoleparser.dialects.creole11_base</span></tt> are possible values.</p>
</dd>
<dt>disable_external_content</dt>
<dd><p class="first last">If True, an error message will be inserted when an externally
hosted image is found.</p>
</dd>
<dt>external_links_class</dt>
<dd><p class="first last">Class attribute to add to external links (i.e., not wiki or interwiki
links).</p>
</dd>
<dt>indent_class</dt>
<dd><p class="first last">Class attribute to add to indented regions.</p>
</dd>
<dt>indent_style</dt>
<dd><p class="first last">Style attribute to add to indented regions.</p>
</dd>
<dt>interwiki_links_base_urls</dt>
<dd><p class="first last">Dictionary of urls for interwiki links. Works like
<tt class="docutils literal"><span class="pre">wiki_links_base_url</span></tt>.</p>
</dd>
<dt>interwiki_links_class_funcs</dt>
<dd><p class="first last">Dictionary of functions that will be called for interwiki link
names and return class attributes. Works like
<tt class="docutils literal"><span class="pre">wiki_links_class_func</span></tt>.</p>
</dd>
<dt>interwiki_links_path_funcs</dt>
<dd><p class="first last">Dictionary of functions that will be called for interwiki link
names and return url paths. Works like <tt class="docutils literal"><span class="pre">wiki_links_path_func</span></tt>.</p>
</dd>
<dt>interwiki_links_space_chars</dt>
<dd><p class="first last">Dictionary of characters that that will be used to replace spaces
that occur in interwiki_links. Works like <tt class="docutils literal"><span class="pre">wiki_links_space_char</span></tt>.
If no key is present for an interwiki name, the
<tt class="docutils literal"><span class="pre">wiki_links_space_char</span></tt> will be used.</p>
</dd>
<dt>macro_func</dt>
<dd><p class="first">If supplied, this fuction will be called when macro markup is found,
unless the macro is in one of macro dictionaries above. The
function must accept the following postional arguments:</p>
<ol class="arabic simple">
<li>macro name (string)</li>
<li>the argument, including any delimter (string)</li>
<li>the macro body (string or None for a macro without a body)</li>
<li>macro type (boolean, True for block macros, False for normal macros)</li>
<li>the <cite>environ</cite> object (see <a class="reference internal" href="core.html#creoleparser.core.Parser.parse" title="creoleparser.core.Parser.parse"><tt class="xref py py-meth docutils literal"><span class="pre">creoleparser.core.Parser.parse()</span></tt></a>)</li>
</ol>
<p class="last">The function may return a string (which will be subject to further wiki
processing) or a Genshi object (Stream, Markup, builder.Fragment, or
builder.Element). If None is
returned, the markup will be rendered unchanged.</p>
</dd>
<dt>no_wiki_monospace</dt>
<dd><p class="first last">If <cite>False</cite>, inline no_wiki will be rendered as &lt;span&gt; not &lt;code&gt;</p>
</dd>
<dt>simple_markup</dt>
<dd><p class="first">List of tuples that each define markup such as <cite>strong</cite> and <cite>em</cite>
that can nest. Each tuple must have two elements, as follows:</p>
<ol class="last arabic simple">
<li>String to match start and end of text to be enclosed.</li>
<li>HTML tag</li>
</ol>
</dd>
<dt>wiki_links_base_url</dt>
<dd><p class="first last">The page name found in wiki links will be smartly appended to this to
form the href. To use a different base url for images, supply a two
element list; the second element will be used.</p>
</dd>
<dt>wiki_links_class_func</dt>
<dd><p class="first last">If supplied, this fuction will be called when a wiki link is found and
the return value (should be a string) will be added as a class attribute
of the corresponding link. The function must accept the page name (any
spaces will have been replaced) as it&#8217;s only argument.
If no class attribute is to be added, return <cite>None</cite>.</p>
</dd>
<dt>wiki_links_path_func</dt>
<dd><p class="first last">If supplied, this fuction will be called when a wiki link is found and
the return value (should be a string) will be joined to the base_url
to form the url for href. The function must accept the page name (any
spaces will have been replaced) as it&#8217;s only argument. Special characters
should be url encoded. To use a different function for images, supply a
two element list; the second element will be used.</p>
</dd>
<dt>wiki_links_space_char</dt>
<dd><p class="first last">When wiki_links have spaces, this character replaces those spaces in
the url. To use a different character for images, supply a two element
list; the second element will be used.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="creoleparser.dialects.creole10_base">
<tt class="descclassname">creoleparser.dialects.</tt><tt class="descname">creole10_base</tt><big>(</big><em>wiki_links_base_url='', wiki_links_space_char='_', interwiki_links_base_urls={}, no_wiki_monospace=True, wiki_links_class_func=None, external_links_class=None, wiki_links_path_func=None, interwiki_links_path_funcs={}, interwiki_links_class_funcs={}, interwiki_links_space_chars={}, blog_style_endings=False, disable_external_content=False, custom_markup=[], simple_markup=[('**', 'strong'), ('//', 'em')], add_heading_ids=False</em><big>)</big><a class="headerlink" href="#creoleparser.dialects.creole10_base" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a base class for extending
(for parameter descriptions, see <a class="reference internal" href="#creoleparser.dialects.create_dialect" title="creoleparser.dialects.create_dialect"><tt class="xref py py-func docutils literal"><span class="pre">create_dialect()</span></tt></a>)</p>
<p>The returned class does not implement any of the proposed additions to
to Creole 1.0 specification.</p>
</dd></dl>

<dl class="function">
<dt id="creoleparser.dialects.creole11_base">
<tt class="descclassname">creoleparser.dialects.</tt><tt class="descname">creole11_base</tt><big>(</big><em>macro_func=None, indent_class=None, indent_style='margin-left:2em', simple_markup=[('**', 'strong'), ('//', 'em'), (',,', 'sub'), ('^^', 'sup'), ('__', 'u'), ('##', 'code')], non_bodied_macros={}, bodied_macros={}, argument_parser=&lt;creoleparser.core.ArgParser object at 0x030E6D10&gt;, **kwargs</em><big>)</big><a class="headerlink" href="#creoleparser.dialects.creole11_base" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a base class for extending (for parameter descriptions, see <a class="reference internal" href="#creoleparser.dialects.create_dialect" title="creoleparser.dialects.create_dialect"><tt class="xref py py-func docutils literal"><span class="pre">create_dialect()</span></tt></a>)</p>
<blockquote>
<p>The returned class implements most of the <em>officially</em> proposed additions to
to Creole 1.0 specification:</p>
<blockquote>
<ul class="simple">
<li>superscript, subscript, underline, and monospace</li>
<li>definition lists</li>
<li>indentation</li>
<li>macros</li>
</ul>
<p>(see <a class="reference external" href="http://purl.oclc.org/creoleparser/cheatsheet">http://purl.oclc.org/creoleparser/cheatsheet</a>)</p>
</blockquote>
</blockquote>
<p><strong>A Basic Extending Example</strong></p>
<p>Extending Creoleparser through subclassing is usually only needed when
custom WikiElement objects are incorporated. However, it is also
needed for other special jobs, like entirely disabling certain markup.
Here we create a dialect that removes image support:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">Base</span> <span class="o">=</span> <span class="n">creole11_base</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">class</span> <span class="nc">MyDialect</span><span class="p">(</span><span class="n">Base</span><span class="p">):</span>
<span class="gp">... </span>    <span class="nd">@property</span>
<span class="gp">... </span>    <span class="k">def</span> <span class="nf">inline_elements</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="gp">... </span>        <span class="n">l</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">MyDialect</span><span class="p">,</span><span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">inline_elements</span>
<span class="gp">... </span>        <span class="n">l</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">img</span><span class="p">)</span>
<span class="gp">... </span>        <span class="k">return</span> <span class="n">l</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">core</span> <span class="kn">import</span> <span class="n">Parser</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">parser</span> <span class="o">=</span> <span class="n">Parser</span><span class="p">(</span><span class="n">MyDialect</span><span class="p">)</span> 
<span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">parser</span><span class="o">.</span><span class="n">render</span><span class="p">(</span><span class="s">&quot;{{this}} is not an image!&quot;</span><span class="p">),</span>
<span class="go">&lt;p&gt;{{this}} is not an image!&lt;/p&gt;</span>
</pre></div>
</div>
<p>For a more complex example, see the <a class="reference external" href="http://code.google.com/p/creoleparser/source/browse/trunk/creoleparser/dialects.py">source code</a>
of this function. It extends the class created from creole10_base().</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">It is generally safest to create only one dialect class per base
class. This is because WikiElement objects are bound as class
attributes and would therefor be shared between multiple instances,
which could lead to unexpected behaviour.</p>
</div>
</dd></dl>

<dl class="function">
<dt id="creoleparser.dialects.creepy10_base">
<tt class="descclassname">creoleparser.dialects.</tt><tt class="descname">creepy10_base</tt><big>(</big><big>)</big><a class="headerlink" href="#creoleparser.dialects.creepy10_base" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a dialect object (a class) to be used by <a class="reference internal" href="core.html#creoleparser.core.ArgParser" title="creoleparser.core.ArgParser"><tt class="xref py py-class docutils literal"><span class="pre">ArgParser</span></tt></a></p>
<p><strong>How it Works</strong></p>
<p>The &#8220;Creepy&#8221; dialect uses a syntax that can look much like that of
attribute definition in xml. The most important differences are that
positional arguments are allowed and quoting is optional.</p>
<p>A Creepy dialect object is normally passed to
<a class="reference internal" href="core.html#creoleparser.core.ArgParser" title="creoleparser.core.ArgParser"><tt class="xref py py-class docutils literal"><span class="pre">ArgParser</span></tt></a> to create a new parser object.
When called with a single argument, this outputs a two-tuple
(a list of positional arguments and a dictionary of keyword arguments):</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">core</span> <span class="kn">import</span> <span class="n">ArgParser</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">my_parser</span> <span class="o">=</span> <span class="n">ArgParser</span><span class="p">(</span><span class="n">dialect</span><span class="o">=</span><span class="n">creepy10_base</span><span class="p">(),</span> <span class="n">convert_implicit_lists</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">my_parser</span><span class="p">(</span><span class="s">&quot; foo=&#39;one&#39; &quot;</span><span class="p">)</span>
<span class="go">([], {&#39;foo&#39;: &#39;one&#39;})</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">my_parser</span><span class="p">(</span><span class="s">&quot;  &#39;one&#39; &quot;</span><span class="p">)</span>
<span class="go">([&#39;one&#39;], {})</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">my_parser</span><span class="p">(</span><span class="s">&quot;  &#39;one&#39; foo=&#39;two&#39; &quot;</span><span class="p">)</span>
<span class="go">([&#39;one&#39;], {&#39;foo&#39;: &#39;two&#39;})</span>
</pre></div>
</div>
<p>Positional arguments must come before keyword arguments. If they occur
after a keyword argument, they will be combined with that value as a list:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">my_parser</span><span class="p">(</span><span class="s">&quot;  foo=&#39;one&#39; &#39;two&#39; &quot;</span><span class="p">)</span>
<span class="go">([], {&#39;foo&#39;: [&#39;one&#39;, &#39;two&#39;]})</span>
</pre></div>
</div>
<p>Similarly, if two or more keywords are the same, the values will be combined
into a list:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">my_parser</span><span class="p">(</span><span class="s">&quot;  foo=&#39;one&#39; foo=&#39;two&#39; &quot;</span><span class="p">)</span>
<span class="go">([], {&#39;foo&#39;: [&#39;one&#39;, &#39;two&#39;]})</span>
</pre></div>
</div>
<p>The lists above are known as &#8220;Implicit&#8221; lists. They can automatically be
converted to strings by setting <tt class="docutils literal"><span class="pre">convert_implicit_lists=True</span></tt> in the
parser.</p>
<p>Quotes can be single or double:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">my_parser</span><span class="p">(</span><span class="s">&#39;&#39;&#39; foo=&quot;it&#39;s okay&quot; &#39;&#39;&#39;</span><span class="p">)</span>
<span class="go">([], {&#39;foo&#39;: &quot;it&#39;s okay&quot;})</span>
</pre></div>
</div>
<p>Tildes can be used for escaping:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">my_parser</span><span class="p">(</span><span class="s">&#39;&#39;&#39; foo=&#39;it~&#39;s okay&#39; &#39;&#39;&#39;</span><span class="p">)</span>
<span class="go">([], {&#39;foo&#39;: &quot;it&#39;s okay&quot;})</span>
</pre></div>
</div>
<p>Quotes are optional if an argument value doesn&#8217;t contain spaces or
unescaped special characters:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">my_parser</span><span class="p">(</span><span class="s">&quot;  one foo = two &quot;</span><span class="p">)</span>
<span class="go">([&#39;one&#39;], {&#39;foo&#39;: &#39;two&#39;})</span>
</pre></div>
</div>
<p>Keyword arguments lacking a value will be interpreted as an empty string:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">my_parser</span><span class="p">(</span><span class="s">&quot; &#39;&#39; foo=  boo= &#39;&#39; &quot;</span><span class="p">)</span>
<span class="go">([&#39;&#39;], {&#39;foo&#39;: &#39;&#39;, &#39;boo&#39;: &#39;&#39;})</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="creoleparser.dialects.creepy20_base">
<tt class="descclassname">creoleparser.dialects.</tt><tt class="descname">creepy20_base</tt><big>(</big><big>)</big><a class="headerlink" href="#creoleparser.dialects.creepy20_base" title="Permalink to this definition">¶</a></dt>
<dd><p>Extends creepy10_base to support an explicit list argument syntax.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">core</span> <span class="kn">import</span> <span class="n">ArgParser</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">my_parser</span> <span class="o">=</span> <span class="n">ArgParser</span><span class="p">(</span><span class="n">dialect</span><span class="o">=</span><span class="n">creepy20_base</span><span class="p">(),</span><span class="n">convert_implicit_lists</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">my_parser</span><span class="p">(</span><span class="s">&quot; one [two three] foo=[&#39;four&#39; &#39;five&#39;] &quot;</span><span class="p">)</span>
<span class="go">([&#39;one&#39;, [&#39;two&#39;, &#39;three&#39;]], {&#39;foo&#39;: [&#39;four&#39;, &#39;five&#39;]})</span>
</pre></div>
</div>
<p>You can test if a list is explicit by testing its class:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">core</span> <span class="kn">import</span> <span class="n">ImplicitList</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pos</span><span class="p">,</span> <span class="n">kw</span> <span class="o">=</span> <span class="n">my_parser</span><span class="p">(</span><span class="s">&quot;  foo=[&#39;one&#39; &#39;two&#39;] boo = &#39;three&#39; &#39;four&#39;&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">kw</span>
<span class="go">{&#39;foo&#39;: [&#39;one&#39;, &#39;two&#39;], &#39;boo&#39;: [&#39;three&#39;, &#39;four&#39;]}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">isinstance</span><span class="p">(</span><span class="n">kw</span><span class="p">[</span><span class="s">&#39;foo&#39;</span><span class="p">],</span> <span class="n">ImplicitList</span><span class="p">)</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">isinstance</span><span class="p">(</span><span class="n">kw</span><span class="p">[</span><span class="s">&#39;boo&#39;</span><span class="p">],</span> <span class="n">ImplicitList</span><span class="p">)</span>
<span class="go">True</span>
</pre></div>
</div>
<p>Lists of length zero or one are <strong>never</strong> of type ImplicitList.</p>
</dd></dl>

</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <h4>Previous topic</h4>
            <p class="topless"><a href="../modules.html" title="previous chapter">Generated API documentation</a></p>
            <h4>Next topic</h4>
            <p class="topless"><a href="core.html" title="next chapter"><tt class="docutils literal docutils literal"><span class="pre">creoleparser.core</span></tt></a></p>
            <h3>This Page</h3>
            <ul class="this-page-menu">
              <li><a href="../_sources/modules/dialects.txt">Show Source</a></li>
            </ul>
          <h3>Quick search</h3>
            <form class="search" action="../search.html" method="get">
              <input type="text" name="q" size="18" /> <input type="submit" value="Go" />
              <input type="hidden" name="check_keywords" value="yes" />
              <input type="hidden" name="area" value="default" />
            </form>
          <!-- Google Sidewiki Element -->
<h3 style="background: url(//www.google.com/sidewiki/static/sidebar_element/img/sidewiki-bubble.png) no-repeat 0 0; padding: .4em 1em .5em 35px; cursor: pointer;" id="sidewiki-open-ui-button">Comments</h3>
<script src="http://www.google.com/sidewiki/static/sidebar_element/sidebar-element-compiled.js"></script>
<script defer="defer">var sidebarElement = new google.elements.sidewiki.SidebarElement(window.location.href,false);sidebarElement.bindToElement("sidewiki-open-ui-button");</script>

        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             accesskey="">modules</a> |</li>
        <li class="right" >
          <a href="core.html" title="creoleparser.core"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="../modules.html" title="Generated API documentation"
             accesskey="P">previous</a> |</li>
        <li><a href="../contents.html">creoleparser v0.7.3 documentation</a> &raquo;</li>
          <li><a href="../modules.html" accesskey="U">Generated API documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
      &copy; Copyright Stephen Day.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.4.
    </div>

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-2934490-7");
pageTracker._trackPageview();
} catch(err) {}</script>

  </body>
</html>